package com.sicheng.datastruct.tree.huffman.huffmancode;

import java.util.Arrays;
import java.util.Objects;


/**
 * @author zsc
 * @version 1.0
 * @date 2021/9/11 13:38
 */
public class HuffmanApp {
    public static void main(String[] args) {

        String content = "i like like like java do you like a java";
        HuffmanCode.Node huffmanTreeRoot = HuffmanCode.initHuffmanTree(content);
        huffmanTreeRoot.preOrder(huffmanTreeRoot);
        System.out.println("###############");
        HuffmanCode huffmanCode = new HuffmanCode();
        Objects.requireNonNull(huffmanCode.getHuffmanCode(content))
                .forEach((key, value) -> System.out.println(key + "===>" + value));

        System.out.println((byte) Integer.parseInt("10101", 2));

//        System.out.println(Arrays.toString(content.getBytes()));
        System.out.println(Arrays.toString(huffmanCode.zip(content)));
    }
}
